﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="frm_Materia.aspx.cs" Inherits="ED_Nivelacion.PresentacionWeb.frm_Materia" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 659px;
        }
        </style>
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="Form1" runat="server">

               <script>
                   function show() {
                       document.write("<head id='head2' runat='server'></head>");
                   }
</script>

            <script>
                $(document).ready(function () {
                    
                    $(document).on("click", ".borrar", function () {

                        var id_asignatura = $(this).data('id_asignatura');

                        alert(id_asignatura);
                        $('#ContentPlaceHolder1_idEliminar').val(id_asignatura);

                    });


                    $(document).on("click", ".editar", function () {

                        var id_materia = $(this).data("id_asignatura");
                        var nombre_materia = $(this).data("nombre_asignatura");

                        $('#ContentPlaceHolder1_txt_Editar').val(id_materia);
                        $('#ContentPlaceHolder1_txt_Materias').val(nombre_materia);
                        $('#ContentPlaceHolder1_btn_Editar_Materia').show();
                        $('#ContentPlaceHolder1_Btn_Guardar_Materias').hide();
                    });

                    $(document).on("click", ".guardar", function () {

                        $('#ContentPlaceHolder1_btn_Editar_Materia').hide();
                        $('#ContentPlaceHolder1_Btn_Guardar_Materias').show();
                    });
                });

                
                function limpiar() {
                    $('#ContentPlaceHolder1_txt_Materias').val("");
                }


</script>

        <% ED_Nivelacion.Negocios.Asignatura_C _objMateria_C = new ED_Nivelacion.Negocios.Asignatura_C(); %>
                <!-- /. ROW  -->

                <div class="row">

                <!-- /. ROW  -->

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                                            <asp:ScriptManager ID="ScriptManager1" runat="server">
                                </asp:ScriptManager>
&nbsp;<asp:Timer ID="Timer1" runat="server">
                                </asp:Timer>
                        <div class="panel panel-default">
                            <div class="panel-body">

<div class="col-lg-12">

                        <div class="portlet portlet-default">
                            <div class="portlet-heading">
                                <div class="portlet-title">
                                    <h4>Agregar Materias</h4>
                                    
                                
                                </div>
                                <div class="clearfix">
                                    <div class ="portlet-widgets"> 
                                        <a class ="btn btn-success btn-xs guardar" data-toggle ="modal" data-target ="#AgregarMateria" onclick="limpiar()"> <i class ="fa fa-plus"> Agregar </i> </a>   
                                    </div>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div class="table-responsive">
                                    <table id="example-table" class="table table-striped table-bordered table-hover table-green">
                                        <thead>

                                            <tr>
                                                <th class="auto-style20">#</th>
                                                <th class="auto-style1">MATERIA</th>
                                                <th class="auto-style21">ACCIÓN</th>
                                            </tr>
                                        </thead>
                                       <tbody>
                                             <%foreach (var item in _objMateria_C.ObtenerAsignatura())
                                              {
                                                  
                                               %>
                                            <tr>
                                                <td><%=item.idAsignatura %></td>
                                                <td class="auto-style1"><%=item.Nombre_Asignatura %></td>
                                                <td class="center"> <a class ="btn btn-orange btn-sm editar" data-toggle ="modal" data-target ="#AgregarMateria" data-id_asignatura="<%=item.idAsignatura %>" data-nombre_asignatura="<%=item.Nombre_Asignatura %>"><i class ="fa fa-pencil"></i>MODIFICAR</a>
                                               </td>
                                            </tr>
                                           <%} %>
                                        </tbody>
                                        <asp:TextBox ID="idEliminar" runat="server" CssClass="hidden"></asp:TextBox>
                                    </table>
                                </div>
                                <!-- /.table-responsive -->
                            </div>
                            <!-- /.portlet-body -->
                        </div>
                        <!-- /.portlet -->

                    </div>
                                <div>
</div>


<div class="col-lg-22">
    <div class="modal modal-flex fade" id="AgregarMateria" tabindex="-1" role="dialog" aria-labelledby="flexModalLabel" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                <h4 class="modal-title" id="flexModalLabel">Agregar Materia</h4>
                                            </div>
                                            <div id="Div1" class="modal-body" runat="server">
                                                <div class="panel panel-default">
 
                            <div class="panel-body">
                                <asp:TextBox ID="txt_Editar" runat="server" CssClass="hidden"></asp:TextBox>
                                     <table class="table table-striped table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                <th>Nombre Materia</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>
                                                    <asp:TextBox ID="txt_Materias" required runat="server" Width="300px" OnTextChanged="Materias_TextChanged"></asp:TextBox>
                                                    <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txt_Materias" FilterType="LowercaseLetters,UppercaseLetters,Custom" ValidChars="ñÑáéíóúÁÉÍÓÚ "  />
                                                </td>
                                            </tr>

                                        </tbody>
                                    </table>
                            </div>
                        </div>
                                            </div>
                                            <div class="modal-footer">
                                             <asp:Button ID="Btn_Guardar_Materias" runat="server" cssclass="btn btn-primary btn-sm" Text="GUARDAR" OnClick="Btn_Guardar_Materias_Click" />
                                             <asp:Button ID="btn_Editar_Materia" runat="server" CssClass=" btn btn-primary btn-sm" Text="EDITAR" OnClick="btn_Editar_Materia_Click" />

                                            </div>
                                        </div>
                                        <!-- /.modal-content -->
                                    </div>
                                    <!-- /.modal-dialog -->
                                </div>
                                <!-- /.modal --> 
               </div>

                                    

                                    </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /. ROW  -->
                        <script>
                            $('[data-id_asignatura]').click(function () {
                                var Id = $(this).data('id_asignatura');
                                $("#ContentPlaceHolder1_idEliminar").val(Id);
                                //alert(Id);
                            });
                            $('[data-toggle="confirmation"]').confirmation({
                                placement: 'top', // How to position the confirmation - top | bottom | left | right
                                trigger: 'click', // How confirmation is triggered - click | hover | focus | manual
                                title: 'Esta seguro?', // Default title value if `data-title` attribute isn't present  
                                template: '<div class="popover" >' +
                                    '<div class="arrow"></div>' +
                                    '<h3 class="popover-title"></h3>' +
                                    '<div class="popover-content text-center">' +
                                    '<div id="botones" class="btn-group">' +
                                    '<asp:LinkButton ID="BtnEliminar" runat="server" CssClass="btn btn-success btn-xs" OnClick="Delete_Click"><i class="fa fa-check-circle icon-white"></i> Si</asp:LinkButton>' +
                                    '<a class="btn btn-xs" data-dismiss="confirmation"></a>' +
                                    '</div>' +
                                    '</div>'
                                , btnOkClass: 'btn-primary'
                                , btnOkIcon: 'fa fa-check-circle'
                                , btnCancelClass: 'btn-danger'
                                , btnOkLabel: 'Si'
                                , btnCancelIcon: 'fa fa-times-circle'
                                , btnCancelLabel: 'No',
                                singleton: true, // Set true to allow only one confirmation to show at a time.
                                popout: false, // Set true to hide the confirmation when user clicks outside of it.
                                onConfirm: function () {

                                }, // Set event when click at confirm button
                                onCancel: function () { }
                            }); // Set event when click at cancel button
                    </script>
        </form>
</asp:Content>
